package test.demo.Result;

import com.sun.xml.internal.ws.developer.Serialization;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import org.apache.ibatis.jdbc.SQL;
import test.demo.Error.ErrorVO;
import test.demo.Exception.SQLException;

@Getter
@Setter
@AllArgsConstructor
@Serialization
public class GlobalResult<T> {

        //操作成功（true）或者失败（false）
        private boolean message;

        //封装的数据对象，传入vo或者自定义的Exception类
        private T data;


        public static GlobalResult<Object> ok() {
            return new GlobalResult<>(true,null);
        }

        public static GlobalResult<String> ok(String msg) {
            return new GlobalResult<>(true,msg);
        }

        public static GlobalResult<Object> ok(Object data) {
            return new GlobalResult<>(true,data);
        }




        public static GlobalResult<Object> error() {
            return new GlobalResult<>(false,null);
        }

        public static GlobalResult<String> error(String msg) {
            return new GlobalResult<>(false,msg);
        }

        public static GlobalResult<ErrorVO> error(ErrorVO error) {
            return new GlobalResult<>(false,error);
        }



}
